""" The mapping from urls to views"""
from django.conf.urls.defaults import patterns, url, include
from django.conf import settings
from smra.smra_portal.views import SMRAAboutView 
from django.views.generic.simple import redirect_to 


 
from django.contrib import admin
admin.autodiscover()
 
           
urlpatterns = patterns('',
    
    url(r'^test/$','smra.smra_portal.views.test'),
    
    url(r'^$', redirect_to, {'url': '%s/virts/' % settings.SUB_SITE}),    
    url(r'^%s/$' % settings.SUB_SITE, redirect_to,
         {'url': '/%s/virts/' % settings.SUB_SITE}),                        
   
    # Retrieve virtual collections
    url(r'^%s/virts/$' % settings.SUB_SITE,
         'smra.smra_portal.views.collections',
        name="publicvirts"),
    
    # Retrieve virtual collections
    url(r'^%s/mycollections/$' % settings.SUB_SITE, 
        'smra.smra_portal.views.my_collections',
        name="virts"),     
    
    # Create and update virtual collection    
    url(r'^%s/virt/(?P<virt_id>\d+)/$' % settings.SUB_SITE,
         'smra.smra_portal.views.update_virt',
        name="virt"), 
     
    # Create and edit metadata for existing virtual colletion    
    url(r'^%s/virt/(?P<virt_id>\d+)/meta/$' % settings.SUB_SITE,
        'smra.smra_portal.views.edit_virt_metadata',
        name="virtmeta"),
                       
                       
    # Create and edit metadata for existing virtual colletion    
    url(r'^%s/virt/(?P<virt_id>\d+)/publish/$' % settings.SUB_SITE,
        'smra.smra_portal.views.publish',
        name="virtpublish"),
                       
     url(r'^%s/rif_cs/$' % settings.SUB_SITE,'smra.smra_portal.views.rif_cs',
        name="rifcs"),
    
    url(r'^%s/about/' % settings.SUB_SITE, SMRAAboutView.as_view(),
        name="about"),
    
    url(r'^%s/virt/$' % settings.SUB_SITE,
         redirect_to, {'url': '/%s/virts/' % settings.SUB_SITE}),

    # Retrieve media objects
    #url(r'^%s/mediaobjects/page(?P<page>[0-9]+)/$' % settings.SUB_SITE, 
    #   MediaObjectListView.as_view(), 
    #    name="browse"), 
    
    # Retrieve media objects
    url(r'^%s/mediaobjects/' % settings.SUB_SITE, 
        'smra.smra_portal.views.media_object_list',
        name="browse"),
                       
    url(r'^%s/mediaobject/(?P<pk>\d+)/$' % settings.SUB_SITE, 
	   'smra.smra_portal.views.mediaobject_details',
       name="details"),
    
    

    url(r'^%s/admin/doc/' % settings.SUB_SITE,
         include('django.contrib.admindocs.urls')),
    
    url(r'^%s/admin/' % settings.SUB_SITE, include(admin.site.urls)),
    
    url(r'^%s/accounts/login/$' % settings.SUB_SITE,
         'django.contrib.auth.views.login', 
	   {'template_name': 'smra_portal/login.html'}),
    url(r'^%s/accounts/logout/$' % settings.SUB_SITE, 
        'django.contrib.auth.views.logout',{'next_page':'/'}),
    
   
    url(r'site_media/(?P<path>.*)$', 'django.views.static.serve',
     {'document_root': settings.STATIC_DOC_ROOT}),
                       
                       
    url(r'^%s/links/$' % settings.SUB_SITE, 
        'smra.smra_portal.views.checklinks',name='deadlinks')             
    
    #url(r'^%s/makelinkcheck/$' % settings.SUB_SITE, 
     #   'smra.smra_portal.views.make_link_check',name='makelinkcheck')
     
     
    #url(r'%s/mint/$' % settings.SUB_SITE,
    #    'smra.smra_portal.views.mint_handle',name='mint')
    )